package com.ysh.controller;


import com.ysh.domain.User;
import com.ysh.service.UserService;
import com.ysh.service.impl.UserServiceImpl;
import org.junit.Test;

import java.util.ArrayList;
import java.util.List;

public class UserController {
    UserService userService = new UserServiceImpl();


    // 1.添加用户信息
    @Test
    public void insertUser(){
        User user = new User("u004","貂蝉",45,"女",120.00);
        int result =userService.addUser(user);
        if (result != 0){
            System.out.println("添加用户，成功！");
        } else{
            System.out.println("添加用户，失败！");
        }
    }

    // 4.查询用户信息
    @Test
    public void findUser(){
        // 集合对象存储User对象
        List<User> list = new ArrayList<>();
        // 调用业务层，得到查询结果的list集合
        list = userService.findUser();
        // 遍历输出
        for (User user : list) {
            System.out.println(user);
        }
    }




    // 6.查询商品信息
}
